<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0,user-scalable=no" name="viewport" />
        <meta content="yes" name="apple-mobile-web-app-capable" />
        <meta content="yes" name="apple-touch-fullscreen" />
        <meta content="telephone=no" name="format-detection" />
        <meta content="black" name="apple-mobile-web-app-status-bar-style">
        <!-- <title>公益捐物</title> -->

        <link href="__PUBLIC__/css/layui.css" rel="stylesheet" type="text/css" media="all"/>
        <script type="text/javascript" src="__PUBLIC__/layui.js"></script>

        <link rel="stylesheet" href="__PUBLIC__/home/css/mlogin.min.css">
    </head>
    
    <body>
        <header id="header" style="display:block;">
            <a href="javascript:history.back();"><span class="icon icon-goback"></a>
            <span class="txt-header">忘记密码</span>
        </header>
        <section class="page">
        <form class="layui-form" method="post">
            <div class="wrap loginPage">
                <span class="txt-header">&nbsp;</span>
                <div class="input-container">
                    <div class="txt-password">手机号：</div>
                    <input class="acc-input password txt-input J_ping" type="text" name="phone" lay-verify="phone" placeholder="请输入要重置密码的手机" autocomplete="off">
                    <i class="icon icon-clear"></i>
                </div>
                <div class="input-container">
                    <div class="txt-password">验证码：</div>
                    <input class="acc-input password txt-input J_ping" type="text" name="yzm" lay-verify="yzm" placeholder="请输入手机验证码" autocomplete="off">
                    <i class="icon icon-clear"></i>
                </div>
                <div class="input-container">
                    <div class="txt-password">新密码：</div>
                    <input class="acc-input password txt-input J_ping" type="password" name="password" lay-verify="password" placeholder="请输入新密码" autocomplete="off">
                    <i class="icon icon-clear"></i>
                </div>
                <div style="text-align: left;">
                    <i class="icon icon-clear"></i>
                </div>
                <a href="javascript:void(0);" id="getCode" onclick="get_mobile_valid();" style="position: absolute;right: 60px;top: 130px;background: #EBA524;padding: 5px;color: #fff;font-size: 10px;border-radius: 5px;">获取验证码</a>

                <div class="notice" style="text-align: center;"><span id="resinfo" style="font-size: 18px;"></span></div>
                
                <p style="padding: 15px;"><a></a></p>
                <button lay-submit="" lay-filter="*" style="background-color: #EBA524;width: 100%;height: 46px;border:0px;" id="tijiaobtn">重置</button>
                
            </div>
        </form>
        </section>
<script type="text/javascript">
    layui.use(['form','layer'], function(){
       $ = layui.jquery;
      var layer = layui.layer
      ,form = layui.form();
      //layer.msg('Hello World');
    //自定义验证规则
    form.verify({
      phone: function(value){
        if(value.length < 1){
          return '请输入手机号';
        }
      }
      ,yzm: function(value){
        if(value.length < 1){
          return '请输入验证码';
        }
      }
      ,password: function(value){
        if(value.length < 1){
          return '请输入新密码';
        }
      }
    });

      //交互
    form.on('submit(*)', function(data){
        $.ajax({
            url: "{:U('user/pass')}",//请求地址
            type: "post",//请求方式
            dataType: "json",//返回数据类型
            data: data.field,//发送的参数
            })
            .done(function(response) {
                  if(response.error==0){
                     layer.msg(response.info ,{icon:5});
                  }else{
                     layer.msg(response.info ,{icon:6});
                     location.href = response.url;
                  }
              })
            .fail(function() {
                alert("ajxs交互失败");
            })  

          return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
        });   
    });

    /*发送短信验证码*/
    function get_mobile_valid(){
        layer.confirm('确认要发送吗？',function(index){
            //发异步删除数据
            var to = $('input[name="phone"]').val();
            $.ajax({
                url: "{:U('index/send_to')}",//请求地址
                type: "post",//请求方式
                dataType: "json",//返回数据类型
                data: {to:to},//发送的参数
                })
                .done(function(response) {
                      if(response.error==1){
                        layer.msg(response.info ,{icon:6});
                      }else{
                        layer.msg(response.info ,{icon:5});
                      }
                  })
                .fail(function() {
                    alert("ajxs交互失败");
                })  
            return false;
        });
    }

</script>
    </body>
</html>